﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text;

public partial class Controls_Activity_GoodInfo : BaseUserControl
{
    public EventHandler OnCancel;

    protected void Page_Load(object sender, EventArgs e)
    {

    }
    public void InitData(string goodId)
    {
        StringBuilder sql = new StringBuilder(string.Format("SELECT T.*,A.SUBJECT AS CategoryName FROM {0} T LEFT JOIN " + GoodsCategoryAccess.TABLE_NAME + " A ON A.NODEID=T.CategoryID ", "IC_Goods"));
        sql.Append(" WHERE 1=1 AND T.GoodsID='").Append(goodId).Append("'");
        DataSet ds = PMSAccess.GetDataSet(this.Connection, sql.ToString(), "IC_Goods");
        PMSAccess.FillDataSet(this.Connection, ds, "select * from IC_GoodsImage where GoodsID='" + goodId + "'", "IC_GoodsImage");
        if (ds.Tables["IC_GoodsImage"].Rows.Count > 0)
        {
            string imgPath = ds.Tables["IC_GoodsImage"].Rows[0]["ThumbImageFileName"].ToString();
            if (!string.IsNullOrEmpty(imgPath))
            {
                imgPhoto.ImageUrl = imgPath;
            }
            else
            {
                imgPhoto.ImageUrl = "~/App_Themes/DefaultSkin/Image/none.gif"; 
            }
        }
        else
        {
            imgPhoto.ImageUrl = "~/App_Themes/DefaultSkin/Image/none.gif"; 
        }
        DataRow dr = ds.Tables[0].Rows[0];
        //P_AllowFeedback.Text = dr["AllowFeedback"].ToString()=="1"?"是":"否";
        P_CategoryID.Text = dr["CategoryName"].ToString(); 
        P_CreateAddress.Text = dr["CreateAddress"].ToString();
        P_Description.Text = dr["Description"].ToString();
        P_GoodsCode.Text = dr["GoodsCode"].ToString();
        P_GoodsDownCount.Text = dr["GoodsDownCount"].ToString();
        P_GoodsMaker.Text = dr["GoodsMaker"].ToString();
        P_GoodsUnit.Text = dr["GoodsUnit"].ToString();
        P_GoodsUpCount.Text = dr["GoodsUpCount"].ToString();
        P_StandardCost.Text = dr["StandardCost"].ToString();
        P_Subject.Text = dr["Subject"].ToString();
        P_TaxCount.Text = dr["TaxCount"].ToString();
        P_TypeModel.Text = dr["TypeModel"].ToString();
        //P_WarningCount.Text = dr["WarningCount"].ToString();

        ds = PMSAccess.GetDataSet(this.Connection, "select T.CodeName from T_CodeConfig T  where T.Category='" + PMSCodeCategory.PMS_BMZB + "' and T.CodeValue in(select GroupCode from IC_GroupGood where GoodID='"+goodId+"')");
        StringBuilder str = new StringBuilder();
        foreach(DataRow row in ds.Tables[0].Rows)
        {
             str.Append(row["CodeName"]).Append("&nbsp;&nbsp;");
        }
        LabelGroup.Text = str.ToString();
    } 
    protected void btnLookImg_Click(object sender, ImageClickEventArgs e)
    { 
    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        if (OnCancel != null)
        {
            OnCancel(sender, e);
        }
    }
}
